<template>
  <div style="background: #FFFFFF;padding: 15px;">
    <div>
      <span style="font-weight: bold;">打包机实时查询</span>
      <a-select default-value="3" style="width: 200px;float: right;" :options="options">
      </a-select>
    </div>
    <div style="display: flex;margin-top: 20px;width: 100%">
      <div style="width: 35%">
        <a-table :columns="columns" :data-source="data" :pagination="false">
          <span slot="temperature" slot-scope="text" style="color: rgb(35, 184, 153)">{{ text }}</span>
          <span slot="humidity" slot-scope="text" style="color: rgb(56, 125, 255)">{{ text }}</span>
        </a-table>
      </div>
      <div style="width: 65%;">
        <div id="main" style="height: 400px;width: 90%"></div>
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'

const columns = [
  {
    title: '',
    dataIndex: 'column1',
    key: 'column1',
    width: 150,
  },
  {
    title: '',
    dataIndex: 'column2',
    key: 'column2',
    width: 150,
    scopedSlots: { customRender: 'temperature' },
  },

]

export default {
  components: {},
  data() {
    return {
      data: [{
        key: '1',
        column1: '垛数',
        column2: 10,
      }],
      columns,
      options: [{
        label: '一纺',
        value: '1'
      }, {
        label: '二纺',
        value: '2'
      }, {
        label: '三纺',
        value: '3'
      }]
    }
  },
  mounted() {
    this.getEchartsData()
  },
  methods: {
    getEchartsData() {
      var myChart = echarts.init(document.getElementById('main'))
      let option = {
        tooltip: {
          trigger: 'axis',
        },
        legend: {
          data: ['', ''],
          right: 30
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['00:00', '02:00', '04:00', '06:00', '08:00', '10:00', '12:00', '14:00', '16:00', '18:00']
        },
        yAxis: [
          {
            type: 'value',
            axisLabel: {
              formatter: '{value} °C'
            }
          },
          {
            type: 'value',
            min: 0,
            max: 100,
            position: 'right',
            axisLabel: {
              formatter: '{value} %'
            }
          }],
        series: [
          {
            name: '温度',
            type: 'line',
            stack: 'Total',
            data: [120, 132, 101, 134, 90, 230, 210, 210, 210, 210]
          },
          // {
          //   name: '湿度',
          //   type: 'line',
          //   stack: 'Total',
          //   data: [220, 182, 191, 234, 290, 330, 310, 210, 210, 210]
          // },
        ]
      }
      myChart.setOption(option)
    },
  }
}
</script>
<style lang="less" scoped>
//#main {
//  width: 70%;
//  height: 400px;
//  margin-left:10px;
//}
</style>

